home *** CD-ROM | disk | FTP | other *** search
/ AmigActive 10 / AACD 10.iso / CDTools / MUIRexx / MCC_Icon / Developer / C / Examples / Icon-Demo.c
C/C++ Source or Header  |  1996-08-16  |  2KB  |  95 lines

  1. /* MUI */
  2. #include <libraries/mui.h>
  3. #include <MUI/Icon_mcc.h>
  4.  
  5. /* System */
  6. #include <exec/exec.h>
  7. #include <dos/dos.h>
  8.  
  9. /* Prototypes */
  10. #include <proto/alib.h>
  11. #include <proto/dos.h>
  12. #include <proto/exec.h>
  13.  
  14. #include <inline/muimaster.h>
  15.  
  16. /* ANSI C */
  17. #include <stdlib.h>
  18. #include <string.h>
  19. #include <stdio.h>
  20.  
  21. struct Library *MUIMasterBase = NULL;
  22.  
  23. static VOID fail(Object *app, char *str)
  24. {
  25.     if (app) MUI_DisposeObject(app);
  26.  
  27.     if (MUIMasterBase) CloseLibrary(MUIMasterBase);
  28.     if (str) {
  29.         puts(str);
  30.         exit(20);
  31.     }
  32.     exit(0);
  33. }
  34.  
  35. static VOID init(VOID)
  36. {
  37.     if (!(MUIMasterBase = (struct Library *) OpenLibrary(MUIMASTER_NAME,MUIMASTER_VMIN-1)))
  38.         fail(NULL,"Failed to open "MUIMASTER_NAME".");
  39. }
  40.  
  41. int main(int argc,char *argv[])
  42. {
  43.     Object *app, *win;
  44.     char *iconname, defname[] = "Icon-Demo";
  45.  
  46.     if (argc < 2) iconname = defname;
  47.     else iconname = argv[1];
  48.  
  49.     init();
  50.  
  51.     app = ApplicationObject,
  52.         MUIA_Application_Title      , "Icon-Demo",
  53.         MUIA_Application_Version    , "$VER: Icon-Demo ["__DATE__"]",
  54.         MUIA_Application_Copyright  , "Written by Russell Leighton, 1996",
  55.         MUIA_Application_Author     , "Russell Leighton",
  56.         MUIA_Application_Description, "Icon-Demo",
  57.         MUIA_Application_Base       , "ICONDEMO",
  58.  
  59.         SubWindow, win = WindowObject,
  60.             MUIA_Window_Title, "Icon-Demo 1996",
  61.             WindowContents, VGroup,
  62.                 Child, IconObject,
  63.                     MUIA_InputMode, MUIV_InputMode_Toggle,
  64.                     MUIA_Frame, MUIV_Frame_Button,
  65.                     MUIA_Icon_Name, iconname,
  66.                 End,
  67.                 Child, TextObject,
  68.                     MUIA_Text_Contents, iconname,
  69.                 End,
  70.             End,
  71.         End,
  72.     End;
  73.  
  74.     if(!app) fail(app,"Failed to create Application.");
  75.  
  76.     DoMethod(win,MUIM_Notify,MUIA_Window_CloseRequest,TRUE,
  77.         app,2,MUIM_Application_ReturnID,MUIV_Application_ReturnID_Quit);
  78.  
  79.     set(win,MUIA_Window_Open,TRUE);
  80.  
  81.     {
  82.         ULONG sigs = 0;
  83.  
  84.         while (DoMethod(app,MUIM_Application_NewInput,&sigs) != MUIV_Application_ReturnID_Quit) {
  85.             if (sigs) {
  86.                 sigs = Wait(sigs | SIGBREAKF_CTRL_C);
  87.                 if (sigs & SIGBREAKF_CTRL_C) break;
  88.             }
  89.         }
  90.     }
  91.  
  92.     set(win,MUIA_Window_Open,FALSE);
  93.     fail(app,NULL);
  94. }
  95.